package momo.Tests;

import static org.junit.Assert.*;
import momo.Library;
import momo.Image;
import org.junit.Test;

/**
 * 
 * @author Mohamed Mosa
 * @version April 29th
 *
 */
public class LibraryTest
{
    private Library library;
    private Image image;

    /**
     * Default constructor for test class LibraryTest
     */
    public LibraryTest()
    {
        library = new Library("hello");
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    protected void setUp()
    {  
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    protected void tearDown()
    {
    }

    @Test
    public void testSetName()
    {
        library.setName("Hi");
    }

    @Test
    public void testGetName()
    {
        assertEquals("hello", library.getName());
    }

    @Test
    public void testGetSize()
    {
        assertEquals(0, library.getSize());
        image = new Image("pic");
        library.add(image);
        assertEquals(1, library.getSize());
    }

    @Test
    public void testAddImage()
    {
        image = new Image("img");
        library.add(image);
    }

    @Test
    public void testRemoveImage()
    {
        image = new Image("img");
        library.add(image);
        assertEquals(1, library.getSize());
        library.remove(image);
        assertEquals(0, library.getSize());
    }

    @Test
    public void testPrintImages()
    {
        image = new Image("img");
        library.add(image);
        library.printImages();
    }

    //@Test
	//public void testSetLibrary()
	//{
	//   library.setLibrary(new java.util.ArrayList<Image>());
	//}

    @Test
	public void testSave() throws Exception
	{
		assertEquals("hello", library.getName());
		library.save();
		assertEquals("hello", library.getName());
	}
	
    @Test
	public void testLoad() throws Exception
	{
    	Library library = new Library("check");
	    assertEquals("check", library.getName());
		library.load();
	    assertEquals("check", library.getName());
	}
}
